package com.tuishan.myapplication.Views;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.blankj.utilcode.util.SPUtils;
import com.hjq.bar.OnTitleBarListener;
import com.hjq.bar.TitleBar;
import com.tuishan.myapplication.Base.BaseContest;
import com.tuishan.myapplication.R;
import com.tuishan.myapplication.Servers.BaseUrl;

public class SetActivity extends Activity implements OnTitleBarListener, View.OnClickListener {
    TitleBar titleBar;
    Button ipSet_btn;
    EditText ip_edit;
    Context mContext;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_set);
        titleBar = findViewById(R.id.titleBar);
        ipSet_btn = findViewById(R.id.ipSet_btn);
        ip_edit = findViewById(R.id.ip_edit);
        titleBar.setOnTitleBarListener(this);
        ipSet_btn.setOnClickListener(this);
        mContext = this;
        ip_edit.setText(SPUtils.getInstance().getString(BaseContest.IPSet, BaseUrl.BASE_URL));
    }

    @Override
    public void onLeftClick(View v) {
        finish();
    }

    @Override
    public void onTitleClick(View v) {

    }

    @Override
    public void onRightClick(View v) {

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.ipSet_btn:
                SPUtils.getInstance().put(BaseContest.IPSet,ip_edit.getText().toString().trim());
                Toast.makeText(mContext, "保存成功", Toast.LENGTH_SHORT).show();
                break;
        }
    }
}
